package com.jiezuo.flowable.app;

import com.jiezuo.flowable.service.MyService;
import org.flowable.engine.ManagementService;
import org.flowable.idm.api.IdmIdentityService;
import org.flowable.idm.api.User;
import org.flowable.ui.common.model.UserRepresentation;
import org.flowable.ui.common.security.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @description   Flowable Modeler获取当前用户，以及绘制流程图时，下拉选项获取用户角色信息
 *               此处的接口名等信息不要变动，Flowable Modeler会自动找这些信息，改变会造成UI找不到这些信息
* @author        庞留杰
* @date          2020/9/10 10:29
* @version       V1.0
**/
@RestController
@RequestMapping("/app")
public class RemoteAccountResource {

    @Autowired
    MyService myService;
    @Autowired
    protected IdmIdentityService idmIdentityService;
    @Autowired
    protected ManagementService managementService;

    /**
    * 功能描述: 查询当前用户信息
    * @author: 庞留杰
    * @exception
    * @date: 2020/9/10 10:30
    */
    @GetMapping(value = "/rest/account", produces = "application/json")
    public UserRepresentation getAccount() {
        User remoteUser = SecurityUtils.getCurrentUserObject();
        //构建用户代表类
        UserRepresentation userRepresentation = new UserRepresentation(remoteUser);
        SecurityUtils.assumeUser(remoteUser); //保证创建流程可用
        return userRepresentation;
    }

}
